Skip to main content

All Questions

0votes
2answers
66views

ActiveRecord query for coaches a client has bookmarked

I'm trying to figure out the best way to set up an ActiveRecord query. Models There are three relevant models involved: ...
Phillip Longman's user avatar
5votes
3answers
97views

Marking loans as paid if the payments exceed the loan amount

I have a Rails app where Loan has paid attribute. Loan should be marked as paid if total sum of payments is equal or higher than loan amount_to_pay. Problem is that ...
Pavel Tkackenko's user avatar
3votes
0answers
118views

Custom MySQL duplicate_key update queries

The goal is to create an activity or update its counter if it's already present. And to be super accurate, the code avoids race conditions with a custom ...
user1035375's user avatar
1vote
2answers
170views

Creating a percentage complete method for a form

I am a relatively new Rails developer and doctor doing research. In my Rails based research projects I often have questionnaires for which I provide a "% complete" parameter. Here is an example. You ...
GhostRider's user avatar
3votes
1answer
48views

Classes for attributes validation

I have two classes responsible for attributes validation: ...
just so's user avatar
2votes
1answer
58views

Authentication and session creation

My session controller has a method for creating new user session. According to Rubocop's output there is 'Assignment Branch Condition' metric is too high [15.17/15]. ...
Alex Nikolaev's user avatar
3votes
2answers
76views

Purchase controller search method

I've been trying to simplify a search method in a project that I've taken over. Is it possible to make the code any cleaner than I already have done? purchase_controller#search (original) ...
Antarr Byrd's user avatar
1vote
1answer
426views

Triggering the execution of a job at the end of a timed campaign

I have a task that checks for campaigns that are supposed to be finished by checking the end_at date. If finished, then set the status of the campaign to finished, ...
Christian Fazzini's user avatar
8votes
3answers
3kviews

Linking issues, classifying the relationship as a cause, effect, superset, etc

I first saw this gigantic if and tried to refactor it. Could only end with a endless switch statement. Old code - ...
eLobato's user avatar

close